package com.hw.basic.myExam;

import java.util.Scanner;

// 小红的正整数构造
//小红拿到了一个区间[l,r]，她希望你在这个区间内找到一个正整数，满足该正整数是x的倍数。你能帮帮她吗？
public class HJ114 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()){
            int l = sc.nextInt();
            int r = sc.nextInt();
            int x = sc.nextInt();
            boolean exsit = false;
            for (int i = l; i <= r; i++) {
                if(i%x==0){
                    exsit =true;
                    System.out.println(i);
                    break;
                }
            }
            if(!exsit){
                System.out.println(-1);
            }
        }
    }
}
